home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
editor
/
htmlhevn.lha
/
HTML-Heaven
/
ARexx
/
HTML-TTX.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-01-08
|
9KB
|
177 lines
/* HTML-Helper Arexx script for TTX (TurboText)
* Ver : 1.2 (7 January 1996)
* Copyright: Cletus Baker (InterNet: cletus@gonix.com)
* Function : Pass on the HTML commands from HTML-Helper to TTX.
* This version adds support for AutoView, which SAVEs
* the document and reloads it into the browser of choice
* for semi-WYSIWYG viewing with each command entered.
* Original created by Paul Kolenbrander with thanks to
* Dan Barrett. Heavily expanded, improved and modified
* by Cletus Baker. (Who also made the TTX-attach script)
* Input : HTMLCMD - The HTML command to be inserted; output from
* HTML-Heaven.
* : AV - The AutoView status; output from HTML-Heaven
*
*
* There are several conditions understood by this script. They
* include whether or not a block is selected, whether or not a
* command contains quotation marks, and whether or not a command
* is a split command containing an open and a close element.
* This script is intended to be intuitive and behaves under each
* possible condition as follows:
*
* 1) Block is selected, command is split; command contains no
* quotation marks:
* The command will be broken and the open and close will be
* pasted on either side of the selected block. The cursor
* is placed at the end of the close, ready for continued body
* text entry.
*
* 2) Block is selected, command is *not* split; command contains no
* quotation marks:
* The command is pasted at the end of the selected block. The
* cursor is placed at the end of the command, ready for
* continued body text entry.
*
* 3) Block is selected, command is split; command *does* contain
* quotation marks:
* The command will be broken and the open and close will be
* pasted on either side of the selected block. In this case,
* the cursor is placed between the first set of quotation
* marks found within the open portion of the command, ready
* for entry of the quoted name or value.
*
* 4) Block is selected, command is *not* split; command *does*
* contain quotation marks:
* The command is pasted at the end of the selected block. The
* cursor is placed between the first set of quotation marks
* found in the command, ready for entry of the quoted name or
* value.
*
* 5) Block is *not* selected, command is split; *whether or not* the
* command contains quotation marks:
* The command is inserted at the current location of the cursor.
* The cursor is then positioned between the open and close
* elements of the command, ready for entry of the text which
* is subject to the command. Where the split command also
* contains quotation marks, don't forget to supply any text
* required there as well.
*
* 6) Block is *not* selected, command is *not* split; command
* contains no quotation marks:
* The command is inserted at the current location of the cursor.
* The cursor is then positioned at the end of the freshly
* pasted command, ready for continued body text entry.
*
* 7) Block is *not* selected, command is *not* split; command
* *does* contain quotation marks:
* the command is inserted at the current location of the cursor.
* The cursor is then positioned between the first set of
* quotation marks found in the command, ready for entry of the
* quoted name or value.
*/
OPTIONS RESULTS /* Enable return codes. */
PARSE ARG AV HTMLCMD /* Snag our HTMLCMD and AV */
HTMLCMD = SUBSTR(HTMLCMD,2, LENGTH(HTMLCMD)-1) /* strip leading space */
If HTMLCMD == "" then do /* If no command, go directly*/
Call AutoView() /* to the AutoView routine,*/
EXIT /* then EXIT the program. */
end
qq = '"'||'"' /* This should avoid a bunch */
qqq = '"'||'"'||'"' /* of quoting gymnastics. */
offset = index(HTMLCMD,qqq) - 1 /* Does HTMLCMD contain any */
/* triple quotes (implying */
/* dbl quotes at its end)? */
HTMLCMD = STRIP((TRANSLATE(HTMLCMD,'','\')), B,'"')
/* Strip quotes at each end. */
ADDRESS 'TURBOTEXT' 'ActivateLastDoc' /* Get the active window */
ADDRESS VALUE RESULT /* ...and address its port. */
GetPrefs AutoEraseBlocks /* Get status of block auto- */
AEBstatus = RESULT /* erasure for later reset. */
SetPrefs AutoEraseBlocks OFF /* Render this pref harmless.*/
GetBlkInfo /* Is a block selected? */
PARSE UPPER VAR RESULT blk vert lblk cblk /* Get the particulars... */
if POS('><',HTMLCMD) ~= 0 then do /* Is it a split command? */
/* If yes, then.... */
if blk = "ON" then do /* If block is selected we: */
MarkBlk /* UNmark the marked block. */
/* Isolate open and close. */
CMD2 = right(HTMLCMD,(LENGTH(HTMLCMD)-(LASTPOS('<',HTMLCMD))+1))
CMD1 = substr(HTMLCMD,1,(LENGTH(HTMLCMD)-LENGTH(CMD2)))
Text CMD2 /* Insert close @ cursor. */
SetBookmark 0 /* Mark our place here. */
Move lblk cblk /* move to start of block. */
Text CMD1 /* Insert the open here. */
quotepos = index(CMD1,qq) /* Check open for dbl quotes.*/
/* If quotes, place cursor...*/
if quotepos > 0 then MoveLeft (length(CMD1)-quotepos)
else do
MoveBookmark 0 /* Otherwise return to mark */
MoveRight (LENGTH(CMD1)) /* and adjust cursor right */
end /* equal to length of CMD1.*/
ClearBookmark 0 /* Pick up after yourself. */
end
else do /* If no block is selected...*/
Text HTMLCMD /* Insert all @ current pos. */
/* ...and move cursor to ctr.*/
MoveLeft (LENGTH(HTMLCMD)+1-LASTPOS('<',HTMLCMD))
end
end
else do /* If not a split command... */
if blk = "ON" then MarkBlk /* UNmark any marked block. */
/* If triple quotes found we */
/* restore dblquotes @ end.*/
if offset >= 0 then HTMLCMD = insert(qq,HTMLCMD,(offset))
Text HTMLCMD /* Insert command @ cursor. */
quotepos = index(HTMLCMD,qq) /* Find location of quotes & */
/* place cursor between. */
if quotepos > 0 then MoveLeft (length(HTMLCMD)-quotepos)
end /* No quotes? Then stay put.*/
SetPrefs AutoEraseBlocks AEBstatus /* Reset AutoEraseBlocks */
Call AutoView() /* Perform AutoView routine */
EXIT
AutoView:
If AV = 'SAVE' then do /* Check for AutoView = ON */
GetFilePath
FileName = RESULT /* Do we have a filename? */
If FileName = "" then do /* If not, open a requester */
SaveFileAs /* for a new filename... */
GetFilePath /* (and then don't forget */
FileName = RESULT /* (to tell me what it is).*/
end
else SaveFile /* otherwise save. */
/* Now reload doc in browser.*/
IF OPEN('tempname', 'T:TempRexxFile', 'READ') ~= 1 THEN DO
OPEN('tempname','T:TempRexxFile','WRITE')
WRITELN('tempname',FileName)
CLOSE('tempname')
ADDRESS COMMAND 'rx S:HTMLVIEW.rexx '||FileName
END
ELSE DO
OLDFILE = READLN('tempname')
IF UPPER(OLDFILE) = UPPER(FileName) THEN DO
ADDRESS COMMAND 'rx S:HTMLVIEW.rexx'
END
ELSE DO
OPEN('tempname','T:TempRexxFile','WRITE')
WRITELN('tempname',FileName)
CLOSE('tempname')
ADDRESS COMMAND 'rx S:HTMLVIEW.rexx '||FileName
END
END
end
return